import { Token } from '@/types/data'
import { LoginAction } from '@/types/store'
import { getToken } from '@/utils/storage'

// const initState:Token = {
//   refresh_token: '',
//   token: ''
// }

// 初始值
const initState:Token = getToken()
console.log(initState)

export default function login (state = initState, action:LoginAction) {
  console.log(action)

  if (action.type === 'login/token') {
    return action.payload
  } else if (action.type === 'login/logout') {
    return initState
  }
  return state
}
